package com.wang.rabbitmq.mqtest;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @author: wang
 * @date: 2021/8/2 20:15
 * @description:
 */
public class MySentDefault {

    public static void main(String[] args) throws IOException, TimeoutException {
        defaultSent();
    }

    public static void defaultSent() throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("192.168.169.123");
        factory.setPort(5672);
        factory.setVirtualHost("/");
        factory.setUsername("root");
        factory.setPassword("root");
        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare("baseQueue", true, false, false, null);
        channel.basicPublish("", "baseQueue", null, "你大爷还是你大爷".getBytes());
        channel.close();
        connection.close();
    }
}
